package Clain;

import Factory.AgriculturalMachine;
import Command.RemoteController;

public class BoundaryViolationHandler extends AbstractSafetyHandler {
    private RemoteController remoteController;

    public BoundaryViolationHandler(RemoteController remoteController) {
        this.remoteController = remoteController;
    }

    @Override
    protected boolean canHandle(SafetyEvent event) {
        return event.getType() == SafetyEventType.BOUNDARY_VIOLATION;
    }

    @Override
    protected void process(SafetyEvent event) {
        System.out.println("【边界违规处理器】处理事件: " + event.getDescription());

        // 获取受影响的农机
        AgriculturalMachine affectedMachine = (AgriculturalMachine) event.getSource();


        // 2. 记录违规信息
        System.out.println("- 违规位置: " + event.getLocation());
        System.out.println("- 违规类型: " + event.getDetails());

        // 3. 引导农机返回安全区域
        System.out.println("- 引导农机返回作业区域");
        // 这里调用路径规划模块生成返回路径

        // 4. 恢复作业
        // remoteController.executeCommand(affectedMachine, new ResumeCommand(returnPath));

        event.setResolved(true);
    }
}